package com.example.spring_ioc.Controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController

public class PropertiesController {
    @Value("${my.key}")
    private String myKey;
    @Value("${my.key2}")
    private Integer myKey2;
    @Value("${my.key3}")
    private Boolean myKey3;

    @PostConstruct //该注解表示在构造该类的对象时就会执行该方法
    public void readValue(){
        System.out.println(("从配置文件中读取配置信息: " + myKey));
        System.out.println(("从配置文件中读取配置信息: " + myKey2));
        System.out.println(("从配置文件中读取配置信息: " + myKey3));
    }
}
